home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 May / PersonalComputerWorld-May2008-CoverdiscCD.iso / Software / Full / Nero 7 / Installation / Cab / 83AF5E4E.cab / IFrameScrollingB70DD318.js < prev    next >
Encoding:
Text File  |  2006-06-20  |  3.7 KB  |  89 lines

  1. function ArrowClick(direction)
  2. {
  3.     // this function responds to mouse click on arrows to scroll iFrame
  4.     oCurFocus = oFrame;
  5.     oCurFocus.focus();
  6.     scrollIframe(direction);
  7. }
  8.  
  9.  
  10. var oFrame;
  11. function setIFrameVariable(iFrameObj)
  12. {
  13.     /* This function is called when the iframe loads. It identifies the iFrame 
  14.     in a global variable to be used in scrolling and focus operations */
  15.     oFrame = iFrameObj;
  16. }
  17.  
  18. function scrollIframe(directionBtn)
  19. {
  20.     // This function is called by either the ArrowClick function or the doOnFocus function
  21.  
  22.     // if focus is not on the scrolling iFrame, exit the function
  23.     if (oCurFocus != oFrame) return
  24.  
  25.     // Create variable for amount that the frame should be scrolled per key press
  26.     var scrollAmnt = 0
  27.     // Set value based on which arrow is pressed
  28.     switch(directionBtn)
  29.     {
  30.         case 38:  // Up arrow selected; scroll up amount indicated by the iFrame's MCScrollAmount attribute
  31.             scrollAmnt = -(oFrame.MCScrollAmount);
  32.             break;
  33.         case 40:  // Down button selected; scroll down amount indicated by the iFrame's MCScrollAmount attribute
  34.             scrollAmnt = oFrame.MCScrollAmount;
  35.             break;
  36.         case 33:    //Page (+) up btn selected; scroll up 40px less than the height of the content
  37.             scrollAmnt = -(oFrame.clientHeight-40);
  38.             break;
  39.         case 34:    // Page down (minus) selected; scroll down 40px less than the height of the content
  40.             scrollAmnt = oFrame.clientHeight-40;
  41.             break;
  42.     }
  43.     // if scroll amount value is not reset by above, then exit function
  44.     if (scrollAmnt == 0) return false;
  45.     // Scroll by amount determined above
  46.     document.frames(oFrame.id).scrollBy(0,scrollAmnt);
  47.     // run function to update arrow buttons on page as needed
  48.     checkArrows();
  49.     return true;
  50. }
  51.  
  52. function checkArrows()
  53. {
  54.     /* This function updates arrow buttons on page by graying out (using alpha opacity filter)
  55.     up or down arrow if you are scrolled all the way to top or bottom */
  56.     // first, turn off filter on both
  57.     arrowUp.style.filter = "none";
  58.     arrowDown.style.filter = "none";
  59.     // Set some variables
  60.     var amountScrolled = document.frames(oFrame.id).document.body.scrollTop; // variable for amount frame has scrolled    
  61.     var totalContentHeight = document.frames(oFrame.id).document.body.scrollHeight; // variable for total height of frame content    
  62.     var scrollFrameHeight = oFrame.clientHeight; // Variable for height of frame    
  63.     var totalYouCanScroll = (totalContentHeight - scrollFrameHeight); // Variable for total amount the content can scroll before you hit the end
  64.  
  65.     // if amount scrolled is <= 0, you are at the top so gray out up arrow
  66.     if (amountScrolled <= 0) arrowUp.style.filter = "alpha(opacity=30)";
  67.     // if amount scrolled is  >= totalYouCanScroll, you are at the bottom so gray out down arrow
  68.     if (amountScrolled >= totalYouCanScroll) arrowDown.style.filter = "alpha(opacity=30)";
  69. }
  70.  
  71. function moveFocusToIFrameContent()
  72. {
  73.     /* This function moves the focus from the iFrame object to the iFrame's content page. It is called
  74.     when focus goes to placeholder span, which is strategically placed at the right on the parent page    */
  75.  
  76.     // For tracking purposes, set oCurFocus variable to iFrame
  77.     oCurFocus = oFrame;
  78.     // Call function on child page to set initial focus on that page
  79.     document.frames(oFrame.id).setContentFocus();
  80. }
  81.  
  82. function moveFocusBackToIFrame()
  83. {
  84.     // This function moves focus from the iFrame's content page back to the iFrame itself on the parent page
  85.     // THis function gets called from the child page
  86.     oCurFocus = oFrame;
  87.     oCurFocus.focus();
  88. }
  89.